package cn.wuyi.item.consumer.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;

import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;

@Service
public class AdminService {
    @Autowired
    private RestTemplate restTemplate;
    
    
    @HystrixCommand(fallbackMethod = "serviceError")
    public String sayHi(String message) {
        return restTemplate.getForObject("http://COMMON-EUREKA-PRODUCER/hello?name=" + message, String.class);
    }
    
    public String serviceError(String message) {
        return "Hi，your message is :\"" + message + "\" but request error.";
    }
}